import { customRef } from "vue";

export default function (value: string, deplay: number) {
    return customRef((track, trigger) => {
        let timer:any = null;
        return {
            get() {
                console.log(value);
                track()    // 通知vue追踪数据的变化
                return value

            },
            set(newVal) {
                console.log(newVal);
                value = newVal

                clearTimeout(timer)

                timer = setTimeout(()=>{
                    trigger()   // 通知Vue去重新解析模板
                },deplay)

            }
        }
    })
}